home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_352 / treewalk / rexx / hackup.ftw < prev    next >
Text File  |  1992-05-06  |  2KB  |  73 lines

  1. /*
  2.  * backup treewalk routine - gets treewalk to check the exclusions
  3.  *    list, and then copies the files that need copying.
  4.  *
  5.  *    Copyright (C) 1989, 1990  Mike Meyer
  6.  *
  7.  *    This program is distributed in the hope that it will be useful,
  8.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10.  */
  11. in = arg(1) || arg(2)
  12.  
  13. out = 'backup'substr(in, index(in, ':'))
  14.  
  15. /* Hack to finish a full backup, just this once
  16. if exists(out) | exists(out'.Z') then return 0
  17. */
  18.  
  19. /* if it passes the basic filter, then do it to it */
  20. '' getclip("daily.backup")
  21. if rc = 0 then
  22.     return copy(in, out)
  23.     
  24. /* Copy things in :lib, always and forever */
  25. if index(in, ':lib/') ~= 0 then
  26.     return copy(in, out)
  27.  
  28. return 0
  29.  
  30. /*
  31.  * copy - makes sure the directory is in place for the destination,
  32.  *    then copies infile to outfile.
  33.  */
  34. copy: procedure
  35.     return 0
  36.     parse arg infile, outfile
  37.  
  38.     address command
  39.  
  40.     /* Is the directory there? */
  41.     outdex = lastpos('/', outfile)
  42.     do while outdex > 0
  43.         outdir = substr(outfile, 1, outdex - 1)
  44.         if exists(outdir) then break
  45.         outdex = lastpos('/', outfile, outdex - 1)
  46.         end
  47.     outdex = index(outfile, '/', outdex + 1)
  48.  
  49.     do while outdex > 0
  50.         outdir = substr(outfile, 1, outdex - 1)
  51.         'makedir "'outdir'"'
  52.         outdex = index(outfile, '/', outdex + 1)
  53.         end
  54.  
  55.     'copy "'infile'" to "'outfile'"'
  56.     'compress "'outfile'"'        /* Copy to ram some day... */
  57.     return rc ~= 0
  58.  
  59. /*
  60.  * Log - log the message we've been given.
  61.  */
  62. log: procedure
  63.     parse arg message
  64.  
  65.     logfile = 'logs:backup.log'
  66.     if ~open(file, logfile, 'Append') then do
  67.         say "Can't open" logfile', exiting!'
  68.         exit
  69.         end
  70.     call writeln file, date() time() || ':' message
  71.     call close file
  72.     return
  73.